// i.d(t, { Z: () => r })
import Sweep from "../object/Sweep"
import OrderedMap from "../utils/OrderedMap"
export default class PanoRenderer {
  textureUsageCounter: {}
  model: any
  sweepList: any
  sweepListMap: OrderedMap
  constructor(e, t) {
    this.textureUsageCounter = {}
    this.model = e
    this.sweepList = t
    const i = new OrderedMap(e => e.id)
    for (let e of this.sweepList) {
      e.isObservableProxy && (e = new Sweep().copy(e))
      i.add(e)
    }
    this.sweepListMap = i
  }
  init() {}
  dispose() {}
  activate(e) {}
  deactivate(e) {}
  beforeRender() {}
  render() {}
  _activateSweep(e) {
    this.initTextureUsage(e)
  }
  _useTexture(e) {
    this.incrementTextureUsage(e)
  }
  freeTexture(e, t = !1) {
    t ? this.setTextureUsage(e, 0) : this.decrementTextureUsage(e)
  }
  initTextureUsage(e) {
    this.textureUsageCounter[e] || (this.textureUsageCounter[e] = 0)
  }
  setTextureUsage(e, t) {
    this.textureUsageCounter[e] = t
  }
  freeUnusedTextures() {
    for (const e of Object.keys(this.textureUsageCounter)) 0 === this.textureUsageCounter[e] && this.freeTexture(e)
  }
  incrementTextureUsage(e) {
    this.textureUsageCounter[e]++
  }
  decrementTextureUsage(e) {
    this.textureUsageCounter[e] > 0 && this.textureUsageCounter[e]--
  }
}
